package com.cloudbroker.openapi.manage.controller;

import com.cloudbroker.bcs.common.entity.HSBCPSBackNumVO;
import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.dav.bizapi.constants.status.ChatMsgType;
import com.cloudbroker.bcs.platform.dav.bizapi.service.base.vo.HSBCPSVO;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.result.*;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.*;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.chat.ChatT2BizService;
import com.cloudbroker.bcs.platform.dav.common.ext.annotation.SaveLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

import static com.cloudbroker.bcs.platform.dav.common.util.RequestUtil.getSingleParameterMapForBody;

@Controller
public class ChatController {
    
    @Resource
    private ChatT2BizService chatT2;
    
    /**
     * 用户禁言/取消
     * */
    @ResponseBody
    @RequestMapping("/func_user_gag")
    @SaveLog(remark = "用户禁言/取消")
    public HSBCPSBackVO funcUserGag(HttpServletRequest request, String jsonpcallback) {
        UserGagForm form = getSingleParameterMapForBody(request, UserGagForm.class);
        return VOUtil.setJsonpResult(chatT2.funcUserGag(form), jsonpcallback);
    }
    
    /**
     * 用户拉黑/取消
     * */
    @ResponseBody
    @RequestMapping("/func_user_block")
    @SaveLog(remark = "用户拉黑/取消")
    public HSBCPSBackVO funcUserBlock(HttpServletRequest request, String jsonpcallback) {
        UserBlockForm form = getSingleParameterMapForBody(request, UserBlockForm.class);
        return VOUtil.setJsonpResult(chatT2.funcUserBlock(form), jsonpcallback);
    }
    
    /**
     * 当日打赏次数
     * */
    @ResponseBody
    @RequestMapping("/func_reward_num_get")
    @SaveLog(remark = "当日打赏次数")
    public RewardNumBackForm funcRewardNumGet(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, HSBCPSVO.class);
        return VOUtil.setJsonpResult(chatT2.funcRewardNumGet(form), jsonpcallback);
    }
    
    /**
     * 设置直播话题
     * */
    @ResponseBody
    @RequestMapping("/func_chatting_topic_set")
    @SaveLog(remark = "设置直播话题")
    public HSBCPSBackVO funcChattingTopicSet(HttpServletRequest request, String jsonpcallback) {
        ChatTopicForm form = getSingleParameterMapForBody(request, ChatTopicForm.class);
        return VOUtil.setJsonpResult(chatT2.funcChattingTopicSet(form), jsonpcallback);
    }
    /**
     * 读取直播话题列表
     * */
    @ResponseBody
    @RequestMapping("/func_get_chat_topic_list")
    @SaveLog(remark = "读取直播话题列表")
    public ChatTopicListResult funcGetChattingTopicList(HttpServletRequest request, String jsonpcallback) {
        ChatTopicListForm form = getSingleParameterMapForBody(request, ChatTopicListForm.class);
        return VOUtil.setJsonpResult(chatT2.funcGetChattingTopicList(form), jsonpcallback);
    }
    /**
     * 聊天室信息查询
     * */
    @ResponseBody
    @RequestMapping("/func_chatroom_info")
    @SaveLog(remark = "聊天室信息查询")
    public ChatRoomInfoBackForm funcChatroomInfo(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, HSBCPSVO.class);
        return VOUtil.setJsonpResult(chatT2.funcChatroomInfo(form), jsonpcallback);
    }
    
    /**
     * 聊天室信息设置
     * */
    @ResponseBody
    @RequestMapping("/func_chatroom_set")
    @SaveLog(remark = "聊天室信息设置")
    public HSBCPSBackVO funcChatroomSet(HttpServletRequest request, String jsonpcallback) {
        ChatRoomSetForm form = getSingleParameterMapForBody(request, ChatRoomSetForm.class);
        return VOUtil.setJsonpResult(chatT2.funcChatroomSet(form), jsonpcallback);
    }
    
    /**
     * 获取缓存历史记录
     * */
    @ResponseBody
    @RequestMapping("/func_get_his_chat")
    @SaveLog(remark = "获取缓存历史记录")
    public ChatHisBackForm funcGetHisChat(HttpServletRequest request, String jsonpcallback) {
        GetCacheChatMsgForm form = getSingleParameterMapForBody(request, GetCacheChatMsgForm.class);
        return VOUtil.setJsonpResult(chatT2.funcGetHisChat(form), jsonpcallback);
    }
    /**
     * 获取数据库聊天历史记录
     * */
    @ResponseBody
    @RequestMapping("/func_preview_his_chat")
    @SaveLog(remark = "获取数据库聊天历史记录")
    public ChatMsgPageResult funcPreviewHisChat(HttpServletRequest request, String jsonpcallback) {
        GetHisChatMsgForm form = getSingleParameterMapForBody(request, GetHisChatMsgForm.class);
        return VOUtil.setJsonpResult(chatT2.funcPreviewHisChat(form), jsonpcallback);
    }
    /**
     * 导出聊天历史记录
     * */
    @ResponseBody
    @RequestMapping("/func_export_his_chat")
    @SaveLog(remark = "导出聊天历史记录")
    public Map<String, Object> funcExportHisChat(HttpServletRequest request, String jsonpcallback) {
        //GetHisChatMsgForm form = getSingleParameterMapForBody(request, GetHisChatMsgForm.class);
        return null;
    }
    
    /**
     * 记录聊天信息
     * */
    @ResponseBody
    @RequestMapping("/func_set_his_chat")
    @SaveLog(remark = "记录聊天信息")
    public HSBCPSBackVO funcSetHisChat(HttpServletRequest request, String jsonpcallback) {
        SetHisChatForm form = getSingleParameterMapForBody(request, SetHisChatForm.class);
        form.setMsg_type(ChatMsgType.MANAGE.getVal());
        return VOUtil.setJsonpResult(chatT2.funcSetHisChat(form), jsonpcallback);
    }
    
    /**
     * 删除聊天信息
     * */
    @ResponseBody
    @RequestMapping("/func_his_chat_del")
    @SaveLog(remark = "删除聊天信息")
    public HSBCPSBackVO funcHisChatDel(HttpServletRequest request, String jsonpcallback) {
        HisChatDelForm form = getSingleParameterMapForBody(request, HisChatDelForm.class);
        return VOUtil.setJsonpResult(chatT2.funcHisChatDel(form), jsonpcallback);
    }
    
    /**
     * 获取大V个人信息
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_broker_info_qry")
    @SaveLog(remark = "获取大V个人信息")
    public BrokerInfoBackForm queryBrokerInfo(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, HSBCPSVO.class);
        return VOUtil.setJsonpResult(chatT2.queryBrokerInfo(form), jsonpcallback);
    }
    
    /**
     * 前端主题颜色选择
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_scheme_color_select")
    @SaveLog(remark = "前端主题颜色选择")
    public HSBCPSBackVO funcSchemeColorSelect(HttpServletRequest request, String jsonpcallback) {
        SchemeColorSelectForm form = getSingleParameterMapForBody(request, SchemeColorSelectForm.class);
        return VOUtil.setJsonpResult(chatT2.funcSchemeColorSelect(form), jsonpcallback);
    }
    
    /**
     * 前端直播地址设置
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_live_broadcast_url_set")
    @SaveLog(remark = "前端直播地址设置")
    public HSBCPSBackVO funcLiveBroadcastUrlSet(HttpServletRequest request, String jsonpcallback) {
        LiveBroadcastUrlForm form = getSingleParameterMapForBody(request, LiveBroadcastUrlForm.class);
        return VOUtil.setJsonpResult(chatT2.funcLiveBroadcastUrlSet(form), jsonpcallback);
    }
    
    /**
     * 聊天室视频直播获取
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_live_broadcast_url_get")
    @SaveLog(remark = "聊天室视频直播获取")
    public LiveBroadcastUrlDetailResult funcLiveBroadcastUrlGet(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, LiveBroadcastUrlForm.class);
        return VOUtil.setJsonpResult(chatT2.funcLiveBroadcastUrlGet(form), jsonpcallback);
    }
    
    /**
     * 聊天室颜色方案设置查询
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_scheme_color_used_get")
    @SaveLog(remark = "聊天室颜色方案设置查询")
    public SchemeColorValueResult funcSchemeColorUsedGet(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, LiveBroadcastUrlForm.class);
        return VOUtil.setJsonpResult(chatT2.funcSchemeColorUsedGet(form), jsonpcallback);
    }
    
    /**
     * 获取讨论区新消息数目
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_new_message_num")
    @SaveLog(remark = "获取讨论区新消息数目")
    public HSBCPSBackNumVO funcNewMessageNum(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, HSBCPSVO.class);
        return VOUtil.setJsonpResult(chatT2.funcNewMessageNum(form), jsonpcallback);
    }
    
    /**
     * 清空讨论区新消息数目
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_clear_message_num")
    @SaveLog(remark = "清空讨论区新消息数目")
    public HSBCPSBackVO funcClearMessageNum(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, HSBCPSVO.class);
        return VOUtil.setJsonpResult(chatT2.funcClearMessageNum(form), jsonpcallback);
    }/**
     * 设置CCLive聊天室ID
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_set_cc_room_id")
    @SaveLog(remark = "设置CCLive直播间ID")
    public HSBCPSBackVO funcSetCCRoomId(HttpServletRequest request, String jsonpcallback) {
        CCRoomInfoFrom form = getSingleParameterMapForBody(request, CCRoomInfoFrom.class);
        return VOUtil.setJsonpResult(chatT2.funcSetCCRoomId(form), jsonpcallback);
    }
    /**
     * 转发CCLive聊天室请求
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_operate_cc_room")
    @SaveLog(remark = "转发CCLive直播间请求")
    public CCRoomOperResult funcOperateCCRoom(HttpServletRequest request, String jsonpcallback) {
        CCRoomOperInfoForm form = getSingleParameterMapForBody(request, CCRoomOperInfoForm.class);
        return VOUtil.setJsonpResult(chatT2.funcOperateCCRoom(form), jsonpcallback);
    }

    /**
     * 关闭/开启CCLive聊天室
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_set_cc_room_status")
    @SaveLog(remark = "关闭/开启CCLive聊天室")
    public HSBCPSBackVO funcSetCcRoomStatus(HttpServletRequest request, String jsonpcallback) {
        CCRoomStatusForm form = getSingleParameterMapForBody(request, CCRoomStatusForm.class);
        return VOUtil.setJsonpResult(chatT2.funcSetCcRoomStatus(form), jsonpcallback);
    }
    
}
